package com.byx.chatclient.entity.message;

import com.byx.chatclient.entity.Constant;
import com.byx.imclientutil.entity.MessageContentType;
import com.byx.imclientutil.entity.MessageType;
import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

public class Message {
     private String uuid;
     private String msgId;
     private MsgType msgType;
     private MsgBody body;
     private MsgSendStatus sentStatus;
     private String senderId;
     private String targetId;
     private long sentTime;


    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getMsgId() {
        return msgId;
    }

    public void setMsgId(String msgId) {
        this.msgId = msgId;
    }

    public MsgType getMsgType() {
        return msgType;
    }

    public void setMsgType(MsgType msgType) {
        this.msgType = msgType;
    }

    public MsgBody getBody() {
        return body;
    }

    public void setBody(MsgBody body) {
        this.body = body;
    }

    public String getSenderId() {
        return senderId;
    }

    public void setSenderId(String senderId) {
        this.senderId = senderId;
    }

    public String getTargetId() {
        return targetId;
    }

    public void setTargetId(String targetId) {
        this.targetId = targetId;
    }

    public MsgSendStatus getSentStatus() {
        return sentStatus;
    }

    public void setSentStatus(MsgSendStatus sentStatus) {
        this.sentStatus = sentStatus;
    }

    public long getSentTime() {
        return sentTime;
    }

    public void setSentTime(long sentTime) {
        this.sentTime = sentTime;
    }

    public Message copy(){
        Message message = new Message();
        message.setMsgId(this.msgId);
        message.setMsgType(this.msgType);
        message.setSenderId(this.senderId);
        message.setTargetId(this.targetId);
        message.setSentStatus(this.sentStatus);
        message.setBody(this.body);
        message.setUuid(this.uuid);
        message.setSentTime(this.sentTime);
        return message;
    }

    public String getSenderNickName(){
        JsonObject jsonObject = JsonParser.parseString(body.getExtra()).getAsJsonObject();
        return jsonObject.get(Constant.JSON_KEY_SENDER_NICK_NAME).getAsString();
    }

    public String getSenderAvatar(){
        JsonObject jsonObject = JsonParser.parseString(body.getExtra()).getAsJsonObject();
        return jsonObject.get(Constant.JSON_KEY_SENDER_AVATAR).getAsString();
    }

    @Override
    public String toString() {
        return "Message{" +
                "uuid='" + uuid + '\'' +
                ", msgId='" + msgId + '\'' +
                ", msgType=" + msgType +
                ", body=" + body +
                ", sentStatus=" + sentStatus +
                ", senderId='" + senderId + '\'' +
                ", targetId='" + targetId + '\'' +
                ", sentTime=" + sentTime +
                '}';
    }
}
